<?php

namespace App\Http\Controllers\Api\O1;

use Illuminate\Http\Request;
use Biz\Resources\Site\WelcomeResource;
use Biz\Services\Site\SiteWelcomeService;
use Laravel\Lumen\Routing\Controller as BaseController;

/**
 * WelcomeController.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class WelcomeController extends BaseController
{
    /**
     * @var mixed
     */
    protected $service;

    /**
     * WelcomeController constructor.
     *
     * @param SiteWelcomeService $service
     */
    public function __construct(SiteWelcomeService $service)
    {
        $this->service = $service;
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index(Request $request)
    {
        $welcome = $this->service->get($request);

        return new WelcomeResource($welcome);
//        $site_id = $request->get('site_id');
//
//        $welcome = $this->service->findBySiteId($site_id);
//
//        $welcomeResource = new SiteWelcomeResource($welcome);
//
//        if($welcome->hasTranslation(config('app.local'))){
//            $welcomeResource->additional([
//                'content' => new SiteWelcomeTranslationsResource($welcome->translate(config('app.local')))
//            ]);
//        }
//
//
//        //dd($welcome->translate('en'));
//
//        return $welcomeResource;
    }
}
